home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / gemfsc18.lzh / AESSRC18.LZH / AESUTIL.S / RCUNION.S < prev    next >
Text File  |  1992-03-15  |  3KB  |  53 lines

  1. ;*************************************************************************
  2. ;* RCUNION.S - Calc the union of two GRECT rectangles.
  3. ;*************************************************************************
  4.  
  5. _rc_union::       
  6.           move.l    4(sp),a1            ; load source pointer
  7.           move.l    8(sp),a0            ; load dest pointer
  8.           movem.l   d3-d4,-(sp)
  9.                                         ; Calc right-side x...
  10.           move.w    (a1),d0             ;  rx1 = x1 + w1 
  11.           add.w     4(a1),d0            
  12.           move.w    (a0),d1             ;  rx2 = x2 + w2
  13.           add.w     4(a0),d1            
  14.           cmp.w     d0,d1               ;  compare rx1 <-> rx2
  15.           bge.s     .gotrx              ;  proper rx is the smaller
  16.           move.w    d0,d1               ;  of the two.
  17. .gotrx:   
  18.                                         ; Calc bottom y...
  19.           move.w    2(a1),d0            ;  by1 = y1 + h1
  20.           add.w     6(a1),d0            
  21.           move.w    2(a0),d2            ;  by2 = y2 + h2
  22.           add.w     6(a0),d2            
  23.           cmp.w     d0,d2               ;  compare by1 <-> by2
  24.           bge.s     .gotby              ;  proper by is the smaller
  25.           move.w    d0,d2               ;  of the two.       
  26. .gotby:                                 
  27.                                         ; Calc left-side x...
  28.           move.w    (a0),d3             ;  assume x2
  29.           cmp.w     (a1),d3             ;  compare x1 <-> x2  
  30.           blt.s     .gotlx              ;  proper lx is smaller
  31.           move.w    (a1),d3             ;  of the two.
  32. .gotlx:                                 
  33.                                         ; Calc top y...
  34.           move.w    2(a0),d4            ;  assume y2
  35.           cmp.w     2(a1),d4            ;  compare y1 <-> y2 
  36.           blt.s     .gotty              ;  proper ty is smaller
  37.           move.w    2(a1),d4            ;  of the two.
  38. .gotty:
  39.                                         ; Got all the x/y's...
  40.           move.w    d3,(a0)+            ; store left x
  41.           move.w    d4,(a0)+            ; store top y
  42.           sub.w     d3,d1               ; compute width
  43.           move.w    d1,(a0)+            ; store it
  44.           sub.w     d4,d2               ; compute height
  45.           move.w    d2,(a0)+            ; store it
  46.  
  47.           movem.l   (sp)+,d3-d4         ; restore regs
  48.           move.l    8(sp),d0            ; return pdest
  49.           rts
  50.  
  51. ;         end of code
  52.  
  53.